<?php

class SimpleController extends \BaseController {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
		//
		return Response::json(simple::get());
	}


	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function create()
	{
		//
	}


	/**
	 * Store a newly created resource in storage.
	 *
	 * @return Response
	 */
	public function store()
	{
		//
			$input = Input::all();
			  $addQue = simple::create($input);
			//$input->save();
			  if($addQue){
			  return Response::json(array('success' => true));
			  }

	}


	/**
	 * Display the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function show($id)
	{
		//
		
		 $detail = DB::table('simple')    //'students'
                ->where('_id', '=', $id)
                ->get();

        // get struc
        //simple::find($id);

        return Response::json($detail);
	}


	/**
	 * Show the form for editing the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function edit($id)
	{
		//
		return "hi";

	}


	/**
	 * Update the specified resource in storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function update($id)
	{
		$user=simple::find($id);
		$abc=Input::all();
		$user->email =$abc['email']; 
		$user->phone=$abc['phone'];
		$user->save();

		  if($user){
		  	//return Input::all();
			  return Response::json(array('success' => true));
		}else{	        
	        return Response::json($detail);	
		
	}
}


	/**
	 * Remove the specified resource from storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function destroy($id)
	{
		//
		simple::destroy($id);

        return Response::json(array('success' => true));
	}


}
